import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2024-09-22
 * Time: 20:23
 */
public class Test {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        BinaryTree.TreeNode root = binaryTree.createTree();
        //String str = "abc##de#g##f###";
        //BinaryTree.TreeNode root = binaryTree.createTree(str);
        System.out.println("======前序======");
        binaryTree.preOrder(root);
        System.out.println();
        List<Character> list1 = binaryTree.preorderTraversal2(root);
        System.out.println(list1);
        System.out.println("======中序======");
        binaryTree.inOrder((root));
        System.out.println();
        List<Character> list2 = binaryTree.inorderTraversal(root);
        System.out.println(list2);
        System.out.println("======后序======");
        binaryTree.postOrder(root);
        System.out.println();
        List<Character> list3 = binaryTree.postorderTraversal(root);
        System.out.println(list3);
        System.out.println("======层序======");
        binaryTree.levelOrder0(root);
        List<List<Character>> list4 = binaryTree.levelOrder(root);
        System.out.println(list4);
        List<List<Character>> list5 = binaryTree.levelOrderBottom(root);
        System.out.println(list5);
        System.out.println("---------------");
        System.out.println("判断一棵树是不是完全二叉树：" + binaryTree.isCompleteTree(root));
        System.out.println("---------------");
        //二叉树前序非递归遍历实现--遍历思路
        binaryTree.preorderTraversal0(root);
        System.out.println("二叉树前序非递归遍历实现--遍历思路: " + binaryTree.list);
        //二叉树前序非递归遍历实现--子问题思路
        List<Character> ret = binaryTree.preorderTraversal(root);
        System.out.println("二叉树前序非递归遍历实现--子问题思路: " + ret);

        // 获取树中节点的个数
        System.out.println("获取树中节点的个数: " + binaryTree.size(root));

        // 获取叶子节点的个数--遍历思路
        binaryTree.getLeafNodeCount0(root);
        System.out.println("获取叶子节点的个数--遍历思路: " + BinaryTree.leafNodeCount);
        // 获取叶子节点的个数--子问题思路
        int leafNodeCount = binaryTree.getLeafNodeCount(root);
        System.out.println("获取叶子节点的个数--子问题思路: " + leafNodeCount);

        //获取第K层节点的个数
        int k = 2;
        int ret2 = binaryTree.getKLevelNodeCount(root,k);
        System.out.println("获取第" + k + "层节点的个数: " + ret2);

        // 获取二叉树的高度
        int ret3 = binaryTree.getHeight(root);
        System.out.println("获取二叉树的高度: " + ret3);

        // 检测值为value的元素是否存在
        char val = 'd';
        BinaryTree.TreeNode ret4 = binaryTree.find(root,val);
        System.out.print("检测值为value的元素是否存在: ");
        if (ret4 == null){
            System.out.println(false);
        }else {
            System.out.println(true);
        }

        System.out.println("是否为对称二叉树: "+binaryTree.isSymmetric(root));
    }
}
